package com.lorianknights.rpg.utils
{
	
	public class Utility extends Object
	{
		
		public function Utility()
		{
			
			super();
			
		}
		
		public static function traceMessage(msg:String):String
		{
			
			trace(msg);
			return msg;
			
		}
		
		public static function numMaxed(num:Number, maxNum:Number):Boolean
		{
			
			return num >= maxNum ? true : false;
			
		}
		
		public function getObject(obj:Object):Object
		{
			
			return !isNull(obj);
			
		}
		
		public static function randomNumber(minRatio:int, maxRatio:int):int
		{
			
			return Math.floor(minRatio * maxRatio) + minRatio;
			
		}
		
		public static function isNull(obj:Object):Boolean
		{
			
			return obj == null;
			
		}
		
		public static function convertXMLToObject(xml:XML):XML
		{
			
			var o:Object = { };
			var obj:Object = { };
			var xO:Object = xml.attributes();
			var childObj:Object = { };
			var s:String = null;
			
				for (obj in xO)
				{
					
					o[String(xO[obj].name())] = String(xO[obj]);
					
				}
				
				xO = xml.children();
				
					for (childObj in xO)
					{
						
						s = xO[childObj].name();
						
						if (o[s] == undefined)
						{
							
							o[s] = [];
							
						}
						
						o[s].push(convertXMLToObject(xO[childObj]));
						
					}
					
					return o;
					
		}
					